﻿using Microsoft.Practices.Unity;
using MiniStock.BusinessLogic.EventDispatcher;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using MiniStock.Database;
using MiniStock.Entities.Common;
using System.Collections.Generic;
using MiniStock.Entities.Stock;

namespace MiniStock.BusinessLogic.EventDispatcher.Test
{
    
    
    /// <summary>
    ///This is a test class for EntityQueryLogicTest and is intended
    ///to contain all EntityQueryLogicTest Unit Tests
    ///</summary>
    [TestClass()]
    public class EntityQueryLogicTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for GetEntityByHash
        ///</summary>
        [TestMethod()]
        public void GetEntityByHashTest()
        {
            SerializationHelper.RegisterKnownEntityTypes(new[] {typeof (Customer)});
            EntityQueryLogic target = new EntityQueryLogic(); 
            target.Context = new EntityDbContext();
            var result = target.GetEntityByHash("Customer|2CE1DD83-9C7B-443A-89FB-E1CF3D402FC9");
        }

        [TestMethod()]
        public void GetEntityByHashTest_Unity()
        {
            SerializationHelper.RegisterKnownEntityTypes(new[] { typeof(Customer) });
            var rootContainer = new UnityContainer();
            var target = rootContainer.Resolve<EntityQueryLogic>();
            var result = target.GetEntityByHash("Customer|2CE1DD83-9C7B-443A-89FB-E1CF3D402FC9");
        }

        /// <summary>
        ///A test for ListEntity
        ///</summary>
        [TestMethod()]
        public void ListEntityTest()
        {
            SerializationHelper.RegisterKnownEntityTypes(new[] { typeof(Customer) });
            EntityQueryLogic target = new EntityQueryLogic();
            target.Context = new EntityDbContext();

            var result = target.ListEntity("Customer", null);
        }
    }
}
